<?php
namespace Yzadmin\Controller;
use Common\Controller\AdminBaseController;
/**
 * 后台留言控制器
 */
class MessageController extends AdminBaseController {

    public function index(){
      check_login();
      $str ='1=1 ';$page_num = 0; $page_num = 10;
      $count = D('Message')->where($str)->count();
      $Page = new \Think\Page($count,25);
      $show = $Page->show();// 分页显示输出
      $list = D('Message')->where($str)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
      $assign=array(
          'lists'=>$list,
          'page'=>$show
      );
      $this->assign($assign);
      $this->display();
    }


    public function edit(){
        $id=I('get.id');
        if (empty($id)){$this->error('非法操作');}
        $info=D('Message')->find($id);
        $assign=array(
            'info'=>$info,
            'id'=>$id
        );
        $this->assign($assign);
        $this->display();
    }



    /*删除操作*/
    function del($id = 0){
      if(IS_POST){
        if(empty($id)){echo 0;exit;}
        $result = D('Message')->where('id='.$id)->delete();
        if($result){
          echo 1;exit;
        }else{
          echo 0;exit;
        }
      }
    }


}
